package net.kong.sns.rest.client;

/**
 * @author <a href="mailto:lanhuai@gmail.com">Ning Yubin</a>
 * @author  Wang Yuanming
 * @version $Id: ErrorResponseException.java,v 1.2.2.1 2009/12/21 09:38:31 wangyuanming Exp $
 */
public class ErrorResponseException extends ApiError {
    private static final long serialVersionUID = 1L;

    private ErrorResponse errorResponse;

    public ErrorResponseException(ErrorResponse errorResponse) {
        this.errorResponse = errorResponse;
    }

    public ErrorResponseException(String message, Throwable throwable) {
        super(message, throwable);
    }

    public ErrorResponse getErrorResponse() {
        return errorResponse;
    }

    @Override
    public String getMessage() {
        return errorResponse.getErrorMsg();
    }

    @Override
    public String toString() {
        String s = super.toString();
        s += " (" + errorResponse.getErrorCode() + ")" ;
        return s;
    }

}
